# -*- encoding: utf-8 -*-

from memory import ESP

class Pop(object):

    """ Classe définissant une instruction POP Ra. """

    def __init__ (self, ra, mem):
        self.__ra = ra
        self.__mem  = mem

    def do (self):
        esp = self.__mem.getRegister(ESP)
        self.__mem.setRegister(
            num = self.__ra,
            newVal = (self.__mem.getRamAt(esp))
            )
        self.__mem.setRegister(ESP, esp + 1)

    def __str__ (self):
        return "pop r{0:d}".format(self.__ra) 

    def __unicode__ (self):
        return self.__str__ () 
